package com.hiwhitley.easy.day15;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by hiwhitley on 2016/8/20.
 */
public class GetRow {
    public List<Integer> getRow(int rowIndex) {
        if (rowIndex == 0) return Arrays.asList(1);
        List<Integer> previousList = getRow(rowIndex - 1);
        List<Integer> thisList = new ArrayList<>();
        for (int i =0; i < previousList.size(); i++) {
            if (i == 0) thisList.add(1);
            if (i > 0) thisList.add(previousList.get(i) + previousList.get(i-1));
            if (i == previousList.size() -1) thisList.add(1);
        }
        return thisList;
    }
}
